import { Provider } from 'react-redux'
import { RouterProvider } from 'react-router'
import { createMemoryRouter } from 'react-router-dom'
import { render } from '@testing-library/react'
import store from '../store/store'
import { routerConfig } from '../routing'

interface WrapperForTestsParams {
	initialRouterPath: string
}

export const setupTestsWrapper = ({
	initialRouterPath,
}: WrapperForTestsParams) => {
	const router = createMemoryRouter(routerConfig, {
		initialEntries: [initialRouterPath],
	})
	render(
		<Provider store={store}>
			<RouterProvider router={router} />
		</Provider>
	)

	return router
}
